<template>
	<view class="content">
		<image class="logo" src="/static/logo.png"></image>
		<view class="text-area">
			<button class="cid"  @click="getCid()">{{cid}}</button>
			<button class="doCid"  @click="pushCid()">{{doCid}}</button>
			<button class="goTO"  @click="goTo()">{{goTO}}</button>
		</view>
		<view class="content" v-for="(item,index) in list"
		:key="item.id">
				{{item.msg}}--------{{index}}
		</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				cid:'获取cid',
				doCid:'推送cid',
				goTO:'进入',
				list:[]
			}
		},
		onLoad() {
			this.getCid();
			// uni.request({
			//     url: 'http://192.168.0.149:9003/test/findInfo', //仅为示例，并非真实接口地址。
			//     success: (res) => {
			//         console.log(res.data);
			//          this.list = res.data.data;
			//     }
			// });
		},
		methods: {
		getCid() {
		    // #ifdef  APP-PLUS
		    console.log('获取cid');
		    var t1 = setInterval(function() {
		        console.log('定时器');
		        //扩展API加载完成事
		        var cid = plus.push.getClientInfo().clientid;
		        if (cid && cid != null && cid != 'null') {
					try {
						console.log(cid);
					     uni.setStorageSync('cid', cid);
					} catch (e) {
						console.log('获取cid失败');
					}
		            clearInterval(t1);
		        }
		    }, 50);
		    // #endif
		},
		pushCid(){
		 const value = uni.getStorageSync('cid');
			uni.request({
			    url: 'http://192.168.0.149:9003/test/getCid?cid='+value,
			    success: (res) => {
			        console.log(res.data);
			    }
			});
			},
		  goTo(){
			  console.log("点击")
			uni.navigateTo({
				url:'/pages/msg/index'
			})
		  }	
		}
	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>

